package com.groupfour.attendancemanagementsystem.dao;


import com.groupfour.attendancemanagementsystem.entity.DO.ProjectGroupDO;
import com.groupfour.attendancemanagementsystem.entity.DO.ProjectGroupMembersDO;
import com.groupfour.attendancemanagementsystem.entity.DO.StudentDO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;


import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface ProjectGroupDao {

    @Insert("insert into project_group(group_code,group_name,is_graduation,delete_status,create_time) values (#{groupCode},#{groupName},#{isGraduation},#{deleteStatus},#{createTime})")
    int addProject(ProjectGroupDO projectGroupDO);

    @Update("update project_group set group_name = #{groupName},update_time = #{updateTime} where group_id = #{groupId}")
    int updateProject(ProjectGroupDO projectGroupDO);

    @Delete("delete from project_group where group_id = #{groupId}")
    int deleteProject(int groupId);

    @Select("select * from project_group where is_graduation = #{isGraduation}")
    List<ProjectGroupDO> selectProject(int isGraduation);

    @Select("select * from project_group where group_id = #{groupId}")
    ProjectGroupDO queryProject(String groupId);

    @Select("select * from project_group where group_name = #{groupName}")
    ProjectGroupDO queryByNameProject(String groupName);

    @Select("select * from project_group")
    List<ProjectGroupDO> selectProjectAll();


    @Insert("insert into project_group_member(group_code,student_code,is_group_leader) values(#{groupCode},#{studentCode},#{isGroupLeader})")
    int addMember(ProjectGroupMembersDO projectGroupMembersDO);

    @Update("update project_group_member set group_code=#{groupCode} where student_code = #{studentCode}")
    int updataMember(String groupCode,String studentCode);

    @Delete("delete from project_group_member where student_code = #{studentCode}")
    int deleteMember(int studentCode);

    @Update("update project_group_member set is_group_leader = #{isGroupLeader} where group_code = #{groupCode}")
    int updateIsGroupleader(int isGroupLeader,String groupCode);

    List<StudentDO> selectMember(Map map);

    @Update("update project_group set group_comment = #{groupComment} ,group_syntnesis_score = #{groupSyntnesisScore} where group_id = #{groupId}")
    int addFraction(String groupComment,double groupSyntnesisScore,int groupId);
}
